package com.sinopec.scandevice.api

import com.sinopec.basemodule.BaseApplication
import com.sinopec.basemodule.currentUser
import com.sinopec.basemodule.http.HttpParamObj
import com.sinopec.basemodule.http.api.HttpResult
import com.sinopec.basemodule.http.api.RetroAPIFactory
import com.sinopec.basemodule.model.app_model.NavigationPageResponseModel
import com.sinopec.basemodule.model.app_model.WarehouseResponseDtos
import io.reactivex.Observable

/**
 * @author lwj
 * @ClassName: AppApi
 * @Description: 主界面
 */
object AppApi {
    private val iService: AppService by lazy {
        RetroAPIFactory.create(AppService::class.java)
    }

    /**
     * 查询设备可切换仓库
     */
    fun listEquipmentWarehouse(): Observable<HttpResult<WarehouseResponseDtos>> {
        val hashMap = HttpParamObj.createParams()
            .putParam("equipmentCode", currentUser.deviceId)
            .end()
        return iService.listEquipmentWarehouse(hashMap)
    }

    /**
     * 切换设备仓库
     */
    fun changeEquipmentWarehouse(stockWarehouseId: String): Observable<HttpResult<Any?>?>? {
        val end = HttpParamObj.createParams()
            .putParam("equipmentCode", BaseApplication.getInstance().userManager.user.deviceId)//设备号
            .putParam("stockWarehouseId", stockWarehouseId)//仓库id
            .end()
        return iService.changeEquipmentWarehouse(end)
    }

    /**
     * 导航页面(v1.1.0)
     */
    fun navigationPage(stockWarehouseId: String?): Observable<HttpResult<NavigationPageResponseModel?>?>? {
        val end = HttpParamObj.createParams()
            .putParam("stockWarehouseId", stockWarehouseId)//仓库id
            .end()
        return iService.navigationPage(end)
    }
}
